package graphics;

import javax.swing.ImageIcon;

import java.awt.Point;

import model.BuildingFactory;
import model.building.Building;

import java.awt.*;

public abstract class GBuildingFactory extends BuildingFactory {

    /** Attributs */
    private GCity m_gCity;
    private ImageIcon m_sprite;

    /** Constructeurs */
    public GBuildingFactory(GCity gCity) {
        super(gCity.getCity());
        m_gCity = gCity;
        m_sprite = new ImageIcon("medias/sprites/" + getName() + ".png");
    }

    /** Accesseurs */
    public GCity getGCity() { return m_gCity; }
    
    /** Predicats */
    public final boolean canConstruct(Point point) 
    { return canConstruct(m_gCity.calculVector3DFrom(point)); }
    
    /** Methodes */
    public abstract Component createGStatusAreaViewer(Building b);

    public final GBuilding construct(Point point) {
        Building building = construct(m_gCity.calculVector3DFrom(point));
        Component gStatusAreaViewer = createGStatusAreaViewer(building);
        return new GBuilding(building, gStatusAreaViewer, m_sprite);
    }
}

